package main.Q1601_1700;

import java.util.Arrays;

public class Q1631_1640 {
    public static void main(String[] args) {
        System.out.println("Question1631：");
        System.out.println("Question1632：");
        System.out.println("Question1633：");
        System.out.println("Question1634：");
        System.out.println("Question1635：");
        System.out.println("Question1636：");
        System.out.println("Question1637：两点之间不包含任何点的最宽垂直区域");
        System.out.println("Question1638：统计只差一个字符的子串数目");
        System.out.println("Question1639：");
        System.out.println("Question1640：");
    }
}

class Question1637 {
    public int maxWidthOfVerticalArea(int[][] points) {
        int[] pointX = new int[points.length];
        for (int i = 0; i < points.length; i++) {
            pointX[i] = points[i][0];
        }
        Arrays.sort(pointX);
        int max = 0;
        for (int i = 1; i < pointX.length; i++) {
            max = Math.max(max, pointX[i] - pointX[i - 1]);
        }
        return max;
    }
}

class Question1638 {
    public int countSubstrings(String s, String t) {
        int m = s.length(), n = t.length();
        int[][] dpl = new int[m + 1][n + 1];
        int[][] dpr = new int[m + 1][n + 1];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                dpl[i + 1][j + 1] = s.charAt(i) == t.charAt(j) ? (dpl[i][j] + 1) : 0;
            }
        }
        for (int i = m - 1; i >= 0; i--) {
            for (int j = n - 1; j >= 0; j--) {
                dpr[i][j] = s.charAt(i) == t.charAt(j) ? (dpr[i + 1][j + 1] + 1) : 0;
            }
        }
        int result = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (s.charAt(i) != t.charAt(j)) {
                    result += (dpl[i][j] + 1) * (dpr[i + 1][j + 1] + 1);
                }
            }
        }
        return result;
    }
}